# This Python file uses the following encoding: utf-8

from django.db import models

from alumnes.models import Grup
from horaris.models import FranjaHoraria


class Franja2ghap(models.Model):
    id_franja2ghap = models.AutoField(primary_key=True)
    franja_kronowin = models.CharField(u'Codi hora al kronowin(0,0=primera hora)', max_length=45, unique=True)
    franja_ghap = models.ForeignKey(FranjaHoraria, null=True, blank=True, db_column='id_franja_horaria')
    class Meta:
        ordering = ['franja_kronowin']  #Ull es un camp numèric dins un camp de text.
        db_table = u'franja2ghap'
        verbose_name = u'Mapeig Franja Horària Ghap Kronowin'
        verbose_name_plural = u'Mapejos Franjes Horàries Ghap Kronowin'
    def __unicode__(self):
        franja = unicode( self.franja_ghap) if self.franja_ghap else u'Sense assignar'
        return  unicode( self.franja_kronowin) + ' -> ' + franja

class Grup2ghap(models.Model):
    id_grup2ghap = models.AutoField(primary_key=True)
    grup_kronowin =  models.CharField(max_length=45, unique=True)
    grup_ghap = models.ForeignKey(Grup, null=True, db_column='id_grup')
    class Meta:
        ordering = ['grup_ghap','grup_kronowin']
        db_table = u'grup2ghap'
        verbose_name = u'Mapeig Grup Ghap Kronowin'
        verbose_name_plural = u'Mapejos Grups Ghap Kronowin'
    def __unicode__(self):
        grup = unicode( self.grup_ghap) if self.grup_ghap else u'Sense assignar'
        return  unicode( self.grup_kronowin) + ' -> ' + grup

class ParametreKronowin(models.Model):
    id_parametre = models.AutoField(primary_key=True)
    nom_parametre =  models.CharField(max_length=45, unique=True, help_text=u'passwd, assignatures amb professor')
    valor_parametre = models.CharField(max_length=240, blank=True)
    class Meta:
        ordering = ['nom_parametre']
        db_table = u'parametre_kronowin'
        verbose_name = u'Paràmetre Kronowin'
        verbose_name_plural = u'Paràmetres Kronowin'
    def __unicode__(self):
        return  unicode( self.nom_parametre ) + ': ' + self.valor_parametre[0:10] + '...'


